package com.bluebamboo.bta;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.JndiRegistry;

/**
 * Hello world!
 *
 */
public class App {

    public static void main(String[] args) throws Exception {
        JndiRegistry jndiRegistry = new JndiRegistry();

        CamelContext context = new DefaultCamelContext(jndiRegistry);

        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("mina:tcp://localhost:9998?textline=true&encoding=UTF-8&timeout=60000&minaLogger=true").process(
                        new MyDataProcessor()).to(
                        "mina:tcp://localhost:9999?textline=true&encoding=UTF-8&timeout=60000&minaLogger=true");
            }
        });

        context.start();

        Thread.sleep(100000);
    }

    private static class MyDataProcessor implements Processor {

        public void process(Exchange exchange) throws Exception {
            System.out.println(exchange.getIn().getBody());
        }

    }

}
